<template>
    <div>
        <van-sticky>
            <van-nav-bar title="电影详情" left-text="返回" left-arrow @click-left="onClickLeft" />
        </van-sticky>
        <div class="filmImg">
            <img :src="'http://218.7.112.123:10001/'+detail.cover" alt="" />
        </div>
        <div class="content" v-html="detail.introduction"></div>

        <div class="comments">
            <h2>观众热评
                <span @click="write">写影评</span>
            </h2>
        </div>
        <div class="audience" v-for="item in commentsList" :key="item.id">
            <div class="user">
                <div class="ad_name">{{item.nickName}}</div>
                <div class="ad_score">评分: {{(item.score)?.toFixed(1)}}</div>
            </div>
            <div class="ad_text" v-html="item.content"></div>
            <div class="ad_other">
                <span class="time">{{item.commentDate}}</span>
                <span class="like iconfont icon-dianzan" @click="point(item.id)">{{item.likeNum}}</span>
            </div>
        </div>
        <div class="buy">
            {{(detail.likeNum/10000).toFixed(2)}}万人想看
            <div class="buy_btn" @click="buy">立即购票</div>
        </div>
        <div class="box"></div>
    </div>
</template>
<script>
import nav from "@/mixin/nav";
import { filmDetail, filmComments, commentsLike } from "@/service/movie/movieService";
export default {
    mixins: [nav],
    data() {
        return {
            detail: {},
            commentsList: [],
        }
    },
    async created() {
        let id = this.$route.params.id;
        console.log(id);
        let { data } = await filmDetail(id);
        console.log(data);
        this.detail = data.data;

        let { data: list } = await filmComments({
            movieId: id
        })
        console.log(list);
        this.commentsList = list.rows;
    },
    methods: {
        onClickLeft() {
            this.$router.go(-1);
        },
        async point(id) {
            let fid = this.$route.params.id;
            let { data } = await commentsLike(id);
            console.log(data);
            let { data: list } = await filmComments({
                movieId: fid
            })
            console.log(list);
            this.commentsList = list.rows;
        },
        write() {
            let fid = this.$route.params.id;
            this.$router.push("/movie/film/comments/" + fid);
        },
        buy() {
            this.$dialog.alert({
                message: "此功能暂未开放,敬请期待!"
            }).then(() => {

            })
        }
    }
}


</script>
<style scoped lang="scss">
.filmImg {
    width: 100%;
    height: 300px;
    margin-bottom: 30px;

    img {
        width: 100%;
        height: 100%;
    }
}

.box {
    height: 50px;
}

.buy {
    position: fixed;
    width: 100%;
    left: 0;
    bottom: 0;
    background-color: #fff;
    z-index: 999;
    padding: 5px;
    height: 50px;
    line-height: 50px;
    color: orange;

    .buy_btn {
        float: right;
        width: 200px;
        line-height: 40px;
        text-align: center;
        background-color: red;
        color: #fff;
        font-size: 20px;
        border-radius: 30px;
        height: 100%;
    }
}

.content {
    padding: 10px;
    text-indent: 20px;
}

.comments {
    padding: 10px;

    h2 {
        height: 30px;
        font-size: 25px;

        span {
            float: right;
            font-size: 12px;
            text-align: center;
            color: #fff;
            background-color: red;
            border-radius: 30px;
            font-weight: 400;
            width: 50px;
            padding: 5px 0;
        }
    }

}

.audience {
    padding: 10px;
    border-bottom: 1px solid #EDEDED;

    .user {
        margin-bottom: 10px;

        .ad_name {
            font-weight: 600;
            font-size: 18px;
        }

        .ad_score {
            color: orange;
        }
    }

    .ad_other {
        margin-top: 10px;
        color: #c3c3c3;
    }

    .like {
        float: right;
    }
}
</style>